<script type="text/javascript">
// <![CDATA[
function getLabel(fieldName){
	var labels = {
	  <?php
	  $count = 0;
	  foreach($form as $formfield){
			$key = $formfield->renderName();
			$val = $formfield->renderLabelName();
			echo "'". html_entity_decode(htmlentities($key, ENT_QUOTES)) ."':'". html_entity_decode(htmlentities($val, ENT_QUOTES)) ."'". (($form->count() - 1 == $count++) ? '' : ','); 
	  }
	  ?>
	};
	return labels[fieldName];
}
</script>